<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%

String path = request.getContextPath();
	String BasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>


<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>川轻化健身房</title>
  <meta name="description" content="Ela Admin - HTML5 Admin Template">
    <meta name="viewport" content="width=device-width, initial-scale=1">




<link rel="stylesheet" href="<%=BasePath%>/static/assets/css/normalize.css">
<link rel="stylesheet" href="<%=BasePath%>/static/assets/css/bootstrap.min.css">
<link rel="stylesheet" href="<%=BasePath%>/static/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="<%=BasePath%>/static/assets/css/themify-icons.css">
<link rel="stylesheet" href="<%=BasePath%>/static/assets/css/style.css">
<link rel="stylesheet" href="<%=BasePath%>/static/vendor/bootstrap/css/bootstrap.css" />
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800' rel='stylesheet' type='text/css'>
<script type="text/javascript"
	src="<%=BasePath%>/static/vendor/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript"
	src="<%=BasePath%>/static/vendor/bootstrap/js/bootstrap.min.js"></script>



</head>

<body>

<div class="modal fade" id="readerUpdateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h1 class="modal-title" align="center"><strong>公告详情</strong></h1>

                <form class="fh5co-form" id="defaultForm">

                    <h3 >公告ID</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text"  class="form-control" id="noticeID"  disabled="true" >
                        </div>
                    </div>
                    <h3 >标题</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text"  class="form-control" id="noticetitle"  disabled="true" >
                        </div>
                    </div>
                    <h3 >类型</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text"  class="form-control" id="type"  disabled="true" >
                        </div>
                    </div>
                    <h3 >发表时间</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text"  class="form-control" id="time"  disabled="true" >
                        </div>
                    </div>

                    <h3 >详情</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <textarea class="form-control" id="content" disabled="ture">
                            </textarea>
                        </div>
                    </div>

                </form>
            </div>
        </div>
    </div>
</div>


	<!-- Left Panel -->
	    <!-- Left Panel -->
    <aside id="left-panel" class="left-panel">
        <nav class="navbar ">
            <div id="main-menu" class="main-menu ">
                <ul class="nav navbar-nav">
                    <li class="menu-item "><a href="../admin/index" class="dropdown-toggle"><i
                            class="menu-icon fa fa-home"></i>主页</a></li>
                    <li class="menu-title">会员管理</li>
                    <!-- /.menu-title -->
                    <li class="menu-item "><a href="../admin/member"
                                              class="dropdown-toggle"> <i class="menu-icon  fa fa-search"></i>查看会员信息
                    </a></li>

                    <li class="menu-title">教练管理</li>
                    <!-- /.menu-title -->
                    <li class="menu-item "><a href="../admin/coachs"
                                                    class="dropdown-toggle"> <i class="menu-icon fa   fa-users"></i>查看教练信息
                    </a></li>
                    <li class="menu-item"><a href="../admin/addcoach"
                                             class="dropdown-toggle"> <i
                            class="menu-icon fa  fa-cut (alias)"></i>激活教练账号
                    </a></li>
                    <li class="menu-title">公告信息管理</li>
                    <li class="menu-item active"><a href="../admin/notice"
                                             class="dropdown-toggle"> <i
                            class="menu-icon fa    fa-location-arrow"></i>查看公告信息
                    </a></li>
                    <li class="menu-item"><a href="../admin/addnotice"
                                             class="dropdown-toggle"> <i class="menu-icon fa    fa-align-justify"></i>添加公告信息
                    </a></li>
					
				</ul>
            </div><!-- /.navbar-collapse -->
        </nav>
    </aside>
    <!-- /#left-panel -->
    <!-- Right Panel -->
    <div id="right-panel" class="right-panel">
        <!-- Header-->
        <header id="header" class="header">
            <div class="top-left">
              <div class="navbar-header">
                   <a class="navbar-brand" href="./"><p style="font-size:30px" >健身房后台管理</p></a>

                   <a id="menuToggle" class="menutoggle"><h4><i class="fa fa-bars fa-lg"></i></h4></a>
                </div>
            </div>
            <div class="top-right">
                <div class="header-menu">
                <div class="header-left">

					</div>
                    <div div class="user-area dropdown float-right">	
                   <span class="text-success"> <%HttpSession name = request.getSession(); %>
                                            <%=name.getAttribute("adminname") %>欢迎你！</span>
                                              </div>


                </div>
            </div>
        </header>

        <div class="content">

            <div class="animated fadeIn">
                <div class="card">
                    <h1 class="text-center">资讯信息管理</h1>
                    <div class="col-md-12">


                        <div class="card-body">
                            <table class="table table-striped table-bordered dateTable no-footer" id="reader_table">
                                <thead>
                                <tr >
                                    <th><h3 align="center">id</h3></th>
                                    <th><h3 align="center">标题</h3></th>
                                    <th><h3 align="center">发表时间</h3></th>
                                    <th><h3 align="center">类型</h3></th>
                                    <th><h3  class="text-warning" align="center">操作</h3></th>
                                </tr>
                                </thead>
                                <tbody>

                                </tbody>
                            </table>

                        </div>
                    </div>
                    <div class="row">
                        <!--分页文字信息  -->
                        <div class="col-md-6" ><p class="lend" id="page_info_area" class="text-success"></p></div>
                        <!-- 分页条信息 -->
                        <div class="col-md-6" i><h2 class="lend" id="page_nav_area"></h2></div>
                    </div>


                </div>
            </div>
        </div>

    </div>

	</div>


    <script src="<%=BasePath%>static/assets/js/vendor/jquery-2.1.4.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/popper.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/bootstrap.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/jquery.matchHeight.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/main.js"></script>
    <script src="<%=BasePath%>/static/assets/js/lib/data-table/datatables.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/lib/data-table/dataTables.bootstrap.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/lib/data-table/dataTables.buttons.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/lib/data-table/buttons.bootstrap.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/lib/data-table/jszip.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/lib/data-table/vfs_fonts.js"></script>
    <script src="<%=BasePath%>/static/assets/js/lib/data-table/buttons.html5.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/lib/data-table/buttons.print.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/lib/data-table/buttons.colVis.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/init/datatables-init.js"></script>
<script type="text/javascript">
    $(function () {
        $.ajax({
            url:"../admin/selectNoticeAll",
            type:"GET",
            success:function (data) {
                build_table(data.data);
            }

        });
    });
    //显示表格数据
    function  build_table(data) {
        $("#reader_table tbody").empty();
        $.each(data,function (i,notice) {
            var readId = $("<td></td>").addClass("classId").append(notice.id);
            var readTitle = $("<td></td>").addClass("classTitle").append(notice.title);
            var readTime = $("<td></td>").addClass("classTime").append(notice.publishtime);
            var readType = $("<td></td>").addClass("classType").append(notice.type);
            var editBtn = $("<button></button>").addClass("btn btn-success btn-lg edit_btn")
                .append($("<span></span>").addClass("glyphicon glyphicon-pencil")).append("查看详情");


            var delBtn =  $("<button></button>").addClass("btn btn-danger btn-lg delete_btn")
                .append($("<span></span>").addClass("glyphicon glyphicon-trash")).append("删除");

            var btnTd = $("<td></td>").append(editBtn).append(" ").append(delBtn);

            $("<tr align='center'></tr>")
                .append(readId)

                .append(readTitle)
                .append(readTime)
                .append(readType)
                .append(btnTd)
                .appendTo("#reader_table tbody");
        });

        $('#bootstrap-data-table-export').DataTable();
    }
    //点击详情按钮
    $(document).on('click','.edit_btn',function () {
        var id = $(this).parents("tr").children("td:nth-child(1)").text();
        $.ajax({
            url:"../admin/selectNoticeByid",
            data:{
                id:id
            },
            type:"GET",
            success:function (data) {
                if(data.msg == "success"){
                    var notice = data.data;
                    $("#noticeID").val(notice.id);
                    $("#noticetitle").val(notice.title);
                    $("#time").val(notice.publishtime);
                    $("#type").val(notice.type);
                    $("#content").val(notice.content);
                    $("#readerUpdateModal").modal({
                        backdrop:"static"
                    });
                }
            }
        });
    });
    //点击删除按钮
    $(document).on('click','.delete_btn',function () {

        var id = $(this).parents("tr").children("td:nth-child(1)").text();
        if(confirm("确定要删除id为："+id+"的记录吗？")){

            $.ajax({
                url:"../admin/deleteNotice",
                data:{
                    id:id
                },
                type:"POST",
                success:function (data) {
                    alert("删除成功");
                    window.location.reload();
                }
            })
        }
    })

</script>

</body>
</html>
